﻿function InitUploader(opts) {
    ///<summary>Init a Uploader</summary>
    ///<param name="opts">E.g:{webRoot:"Http://xxxx/",rel:"category",uploader:"SWF"}</param>
    window.scrollTo(0, 0);

    var size = { 'height': 320, 'width': 550 };
    var iframe = document.createElement('iframe');
    iframe.name = 'Portal Uploader';
    iframe.id = 'PortalUploader';
    iframe.src = opts.webRoot + 'admin/Pages/upload.aspx?rel=' + opts.rel+'&relval='+opts.relval + '&uploader=' + opts.uploader+'&limit='+opts.limit+"&isImg="+opts.isImg;
    iframe.style.height = size.height + 'px';
    iframe.style.width = size.width + 'px';

    iframe.style.backgroundColor = 'white';
    iframe.style.border = '1px solid #888';
    iframe.frameborder = '0';

    $(iframe).attr("title","文件上传部件");
    document.body.appendChild(iframe);

    $("#PortalUploader").dialog({
        modal: true,
        width: 580,
        height: 380,
        resizable: false,
        overlay: {
            opacity: 0.5,
            background: "black"
        },
        close: function() {
            $("#PortalUploader").dialog("destroy").remove();
        }
    });
}